namespace AdminApiTemplate.Common.Helpers
{
    public class SKHelper
    {
        private const string sk_check = "1523467890";

        public static bool Check(string? sk)
        {
            if (!string.IsNullOrEmpty(sk))
            {
                var sum = 0;
                for (var i = 0; i<sk.Length-2; i++)
                {
                    sum+=sk[i];
                }
                return sk_check[sum%10]== sk[sk.Length-1];
            }

            return false;
        }

        public static string Create(string sk)
        {
            var sum = 0;
            for (var i = 0; i<sk.Length-1; i++)
            {
                sum+=sk[i];
            }
            return $"{sk}{sk_check[sum%10]}";
        }
    }
}
